package com.twoandone.tms.realtime.publisher.controller;

import com.twoandone.tms.realtime.publisher.service.WaybillService;
import com.twoandone.tms.realtime.publisher.util.DateFormatUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController

public class WaybillController {
    @Autowired
    WaybillService waybillService;
    @RequestMapping("/getallcount")
    public String getAllCount (@RequestParam(value = "date",defaultValue = "0") Integer date){
        if (date == 0) {
            date = DateFormatUtil.now();
        }
        Long count = waybillService.getAllCount(date);
        String result = "{\"status\": 0,\"data\": " + count + "}";
        return result;
    }
    @RequestMapping("/getallsum")
    public String getAllSum (@RequestParam(value = "date",defaultValue = "0") Integer date){
        if (date == 0) {
            date = DateFormatUtil.now();
        }
        Long sum = waybillService.getAllSum(date);
        String result = "{\"status\": 0,\"data\": " + sum + "}";
        return result;
    }

}
